﻿@using SmartSiteManagementSystem.Models.Material;
@using SmartSiteManagementSystem.IServices;
@inject IMaterialService _materialService
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    ViewBag.BodyClass = "easyui-layout";
    MaterialInfo materialInfo = ViewBag.materialInfo;
}
    <div class="easyui-panel" style="padding:5px;">    
        <input id="MaterialId" type="hidden" value="@materialInfo.MaterialId" />
        <table class="gou-formTable" style="align-content:center;">
            <tbody>              
                <tr>
                    <td align="right" class="gou-formTable-title" style="width:160px;">*物料名:</td>
                    <td align="left" class="">
                         <input id="MaterialName" name="MaterialName" type="text" value="@materialInfo.MaterialName" />    
                    </td>
                </tr>
            <tr>
                <td align="right" class="gou-formTable-title"><font style="color:red;">*</font>物料分类：</td>
                <td align="left">@Html.Partial("~/Views/Shared/ComboMaterialCatalog.cshtml")</td>
            </tr>                    
                <tr>
                    <td align="right" class="gou-formTable-title">净重:</td>
                    <td align="left" class="">                        
                        <input id="SingleWeight" name="SingleWeight" type="text" value="@materialInfo.SingleWeight" /> 
                    </td>
                </tr>

            <tr>
                <td align="right" class="gou-formTable-title" style="min-width:70px;">商品排序：</td>
                <td align="left">
                    <input id="SortOrder" name="SortOrder" value="0" class="easyui-numberbox" precision="0" required="true" missingmessage="请输入整数" value="@materialInfo.SortOrder" />
                </td>
            </tr>                
               

                <tr>
                    <td align="right" class="gou-formTable-title">描述:</td>
                    <td align="left" class="">
                        <input id="Descript" name="Descript" type="text" value="@materialInfo.Descript" />

                    </td>
                </tr>

                <tr>
                    <td colspan="2" align="center">                       
                            <a href="javascript:void(0)" id="hfSave" class="easyui-linkbutton" iconcls="icon-save" onclick="SaveMaterial();" style="width:150px;height:32px">保存</a>                                           
                    </td>
                </tr>
            </tbody>
        </table>

    </div>



    <script type="text/javascript">        


        //保存
        function SaveMaterial() {

            //验证必选项******************************************************************
            var MaterialName = $("#MaterialName").val();
            if (MaterialName == "") {
                $.messager.alert('提示', '物料名称为必填项!');
                return false;
            }
             //物料分类
             var MaterialCatalog = jQuery("[name=combo_materialCatalog_Third]").val();
             if (MaterialCatalog == 0) {
                    $.messager.alert('提示信息', "请选择物料分类", 'info').panel('move', {
                        top: 100
                    });
                    return;
             }
              var SingleWeight=$("#SingleWeight").val();

            var SortOrder= $("#SortOrder").val();
            var Descript = $("#Descript").val();
            var MaterialId = $("#MaterialId").val();

         
            
            var param = { MaterialId: MaterialId, MaterialName: MaterialName, CatalogId: MaterialCatalog, SingleWeight: SingleWeight, SortOrder: SortOrder, Descript: Descript};
            $.ajax({
                "type": "Post",
                "url": "ajaxAccess?t=" + new Date().getTime(),
                "dataType": "json",
                "data": param,
                "success": function (data) {
                 if (data.IsSuccess) {
                    window.location.href = "index";
                }
                else {
                    $.messager.alert('提示', '保存失败');
                }
              }
            });
        }
</script>    
